package at.jku.novellbedsidedevice.datasource.calllog;

import java.util.Date;

import android.provider.CallLog;
import at.jku.novellbedsidedevice.datasource.AbstractDataObject;

public class CallLogDataObject extends AbstractDataObject {
	String telephoneNumber;
	String name;
	CallType callType;

	public CallLogDataObject(Date date, String telephoneNumber, String name, CallType callType) {
		super(date);
		this.telephoneNumber = telephoneNumber;
		this.name = name;
		this.callType = callType;
	}

	public String getTelephoneNumber() {
		return telephoneNumber;
	}

	public void setTelephoneNumber(String telephoneNumber) {
		this.telephoneNumber = telephoneNumber;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public CallType getCallType() {
		return callType;
	}

	public void setCallType(CallType callType) {
		this.callType = callType;
	}

	public enum CallType {
		INCOMING, OUTGOING, MISSED;

		public static CallType toCallType(int type) {
			if (type == CallLog.Calls.INCOMING_TYPE)
				return INCOMING;
			else if (type == CallLog.Calls.OUTGOING_TYPE)
				return OUTGOING;
			return MISSED;
		}
	}

	@Override
	public String toString() {
		return name + " | " + telephoneNumber + " | " + getDate().toString() + " | " + callType.toString();
	}

}
